package com.qzf.test.utils;

import com.qzf.test.model.Brand;
import com.qzf.test.model.Cell;
import com.qzf.test.model.Layer;

public class LayerUtils {
    public static Layer builderLayer(Integer rowNum, Integer colNum){
        Layer layer =new Layer(rowNum,colNum);

        Brand[] brands = BrandUtils.builderBrand(layer.getCapacity());

        Cell[][] cells =layer.getCells();

        int flag=0;
        for (int row =0;row<cells.length;row++) {
            for (int col = 0; col < cells[row].length; col++) {
                Brand brand=brands[flag++];
                Cell cell = new Cell();
                cell.setState(1);
                cell.setBrand(brand);
                brand.setCell(cell);
                cells[row][col] = cell;
            }
        }

        return layer;
    }
}
